﻿using LiveShopvnext.Commodity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;


namespace LiveShopvnext.Product
{
    public class ProductAppService
        : CrudAppService<Commodity.Product, ProductDto, int, ProductListDto, CreateUpdateProductDto>,IProductAppService
    {
        private readonly IRepository<Commodity.Product, int> _repository;
        public ProductAppService(IRepository<Commodity.Product, int> repository) : base(repository)
        {
            _repository = repository;
        }

        [Obsolete]
        protected override IQueryable<Commodity.Product> CreateFilteredQuery(ProductListDto input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(!string.IsNullOrEmpty(input.productName),c=>c.productName.Contains(input.productName))             //产品名称
                .WhereIf(!string.IsNullOrEmpty(input.productSubtitle),c=>c.productSubtitle.Contains(input.productSubtitle)) //产品副名称
                .WhereIf(input.productTypeId>0,c=>c.productTypeId==input.productTypeId)                                     //产品分类主键
                .WhereIf(input.productState>0,c=>c.productState==input.productState)                                        //是否上架
                .WhereIf(input.productDisplay>0,c=>c.productDisplay==input.productDisplay);                                 //逻辑删除
        }
    }
}
